package com.example.ethereum.dto;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@ApiModel(description = "统一响应结果")
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ApiResponse<T> {
    
    @ApiModelProperty(value = "是否成功", example = "true")
    private boolean success;
    
    @ApiModelProperty(value = "响应消息", example = "Success")
    private String message;
    
    @ApiModelProperty(value = "响应数据")
    private T data;

    public static <T> ApiResponse<T> success(T data) {
        return new ApiResponse<>(true, "Success", data);
    }

    public static <T> ApiResponse<T> success(String message, T data) {
        return new ApiResponse<>(true, message, data);
    }

    public static <T> ApiResponse<T> error(String message) {
        return new ApiResponse<>(false, message, null);
    }
}

